import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @User: vitobo
 * @Date: 2024-09-04
 * @Description: 重定向位置URL, 发送临时重定向响应到客户端;
 */

@WebServlet("/Redirect")
public class RedirectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //resp.sendRedirect("https://www.baidu.com");
        resp.setStatus(302);
        resp.setHeader("Location", "https://www.baidu.com");
    }
}
